<%--
  Created by IntelliJ IDEA.
  User: bin.liu
  Date: 2018/12/5
  Time: 11:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-trophy"></i> 紧急程度管理
            </div>
            <div class="box-tools pull-right">
                <sec:authorize access="hasRole('ROLE_ENTERPRISE_REPAIR_LEVEL_EDIT')">
                    <a href="javascript:;" onclick="vLayuiUtil.openLayerWindow('wRepairLevel','<c:url
                            value="/web/admin/repairLevel/editPage.action"/>','新增',['80%', '95%'])"
                       class="btn btn-default btnTool" title="新增"><i class="fa fa-plus"></i> 新增</a>
                </sec:authorize>
            </div>
        </div>

        <div class="box-body">
            <form id="searchForm" action="<c:url value="/web/admin/repairLevel/listJson.action"/>" method="post"
                  class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
            </form>
            <div style="overflow-x:auto">
                <table id="dataGrid"></table>
            </div>
            <div id="dataGridPage"></div>
        </div>
    </div>
</div>
<script>
    var selectIds = [];
    $('#dataGrid').dataGrid({
        shrinkToFit: false,
        autoScroll: true,
        searchForm: $("#searchForm"),
        columnModel: [
            <sec:authorize access="hasRole('ROLE_ENTERPRISE_REPAIR_LEVEL_EDIT')">
            {
                header: '操作',
                name: 'actions',
                width: 200,
                frozen:true,
                sortable: false,
                title: false,
                formatter: function (val, obj, row, act) {
                    var a = '<a  class="btn btn-default btn-xs btnList" onclick="editRepairOrder(' + row.id + ')" title="编辑"><i class="fa fa-pencil"></i>编辑</a>&nbsp;';
                    return a;
                }
            },
            </sec:authorize>
            {header: '主键id', name: 'id', index: 'id', width: 100, align: "center", edittype: "checkbox"},
            {header: '程度名称', name: 'grade', index: 'grade', width: 250, align: "center"},
            {header: '需求到场距创建时间（分钟）', name: 'presenceTime', index: 'presenceTime', width: 250, align: "center", sortable: false},
            {header: '需求完成距创建时间（分钟）', name: 'finishTime', index: 'finishTime', width: 250, align: "center", sortable: false},
            {header: '所属企业', name: 'enterpriseName', index: 'enterpriseName', width: 150, align: "center",sortable: false},
            {header: '创建时间', name: 'createDate', index: 'createDate', width: 200, align: "center"}
        ]
    });
    $("#dataGrid").dataGrid('setFrozenColumns');


    function editRepairOrder(id) {
        vLayuiUtil.openLayerWindow('wRepairLevel', '<c:url value="/web/admin/repairLevel/editPage.action?id="/>' + id, '编辑', ['80%', '95%'])
    }



    function submitRemove(id) {
        $.ajax({
            type: 'post',
            url: "<c:url value="/web/admin/repairOrder/delete.action" />",
            data: {"id": id},
            dataType: 'json',
            async: false,
            success: function (data) {
                js.showMessage(data.msg);
                $('#dataGrid').dataGrid('refresh');
            },
            error: function () {
                js.showMessage("出错了，请联系管理员");
            }
        });
    }

    //指定岗位和人员 type:0人员，1：岗位
    function assign(type) {
        var ids = $("#dataGrid").jqGrid("getGridParam", "selarrrow");
        if (ids.length == 0) {
            js.showMessage("请选择要派单的维修单");
            return false;
        }
        if (ids.length > 1) {
            js.showMessage("只能选择一条维修单进行派单");
            return false;
        }
        if (type == 0) {
            vLayuiUtil.openLayerIframMaxWindow('wAssignUser', '<c:url value="/web/admin/repairOrder/assignUser.action?repairOrderId="/>' + ids, '指定接单人')
        }
        if (type == 1) {
            vLayuiUtil.openLayerIframMaxWindow('wAssignPosition', '<c:url value="/web/admin/repairOrder/assignPosition.action?repairOrderId="/>' + ids, '指定岗位')
        }

    }


    function  downloadData() {
        // ajaxLoading('container1');
        // setTimeout(function () {
        //     $(".datagrid-mask").remove();
        //     $(".datagrid-mask-msg").remove();
        // },2000);
        var reportCode=$('#reportCode').val( );
        var orderStatus=$('#orderStatus').val( );
        window.location.href = encodeURI(encodeURI('<c:url value="/web/admin/repairOrder/exportOrder.action" />?reportCode='+reportCode + '&orderStatus='+orderStatus));
    }

</script>
